package com.dms.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.SecurityFilterChain;

@Configuration
@Order(1)
public class SwaggerSecurityConfig {

    @Bean
    public SecurityFilterChain swaggerSecurityFilterChain(HttpSecurity http) throws Exception {
        http
            .requestMatchers()
                .antMatchers(
                    "/swagger-ui.html",
                    "/swagger-resources/**",
                    "/v2/api-docs",
                    "/v3/api-docs",
                    "/webjars/**",
                    "/favicon.ico",
                    "/swagger-ui/**",
                    "/swagger-ui/index.html"
                )
            .and()
            .authorizeRequests()
                .antMatchers(
                    "/swagger-ui.html",
                    "/swagger-resources/**",
                    "/v2/api-docs",
                    "/v3/api-docs",
                    "/webjars/**",
                    "/favicon.ico",
                    "/swagger-ui/**",
                    "/swagger-ui/index.html"
                ).permitAll()
            .and()
            .csrf().disable();
            
        return http.build();
    }
} 